<template>
  <view>
    <view>
      <nui-guide v-if="showGuide" :guideList="guideList" @curIndex="curIndex"></nui-guide>
      <!-- <iframe :src="iframePath" class="iframe" frameborder="0" width="100%" height="100%"></iframe> -->
      <view class="download-box">
        <image :src="downloadImg" class="ewm">
        <text class="tips">长按上方二维码</text>
      </view>
      <view class="faxin-guide" v-if="isShowGuide"></view>
      <view class="faxin-guide_1" v-if="isShowGuide1"></view>
      <u-button type="primary" shape="square" :ripple="true" size="medium" class="custom-btn" @click="toPath"
        >{{ showGuide? '已下载美团，下一步' : '已添加站长微信，下一步' }}</u-button
      >
    </view>
  </view>
</template>

<script>
import {isEmpty} from "@/utils";
import { mapGetters } from "vuex";
import * as consts from "@/utils/constant.js";
export default {
  data() {
    return {
      showGuide:false,
      iframePath: "",
      downloadImg: `${consts.API_BASE_URL}/xsdcrm-static/template/meituan.png`,
      guideList: [
        {
          el: ".ewm", // 需要高亮的元素，这里最好唯一
          tips: "① 手指放在这，长按这里", // 提示文字
          next: "下一步", // 下一步按钮显示文字
          style: {
            // 高亮样式
            borderRadius: "12px",
            width: "200px",
            height: "200px",
          },
          tipStyle: {
            // tips样式
            left: "10px",
            top: "220px",
            atop: "217px",
          },
        },
        {
          el: ".faxin-guide", // 需要高亮的元素，这里最好唯一
          tips: "② 点击这里,进入美团下载页", // 提示文字
          next: "下一步", // 下一步按钮显示文字
          style: {
            // 高亮样式
            borderRadius: "5px",
            width: "160px",
            height: "40px",
            left: "27%",
            top: "82vh",
          },
          tipStyle: {
            // tips样式
            left: "0px",
            top: "-77px",
            atop: "-27px",
          },
        },
        {
          el: ".faxin-guide_1", // 需要高亮的元素，这里最好唯一
          tips: "③ 点击这里下载美团", // 提示文字
          next: "下一步", // 下一步按钮显示文字
          style: {
            // 高亮样式
            borderRadius: "12px",
            margin: "-5px 0 0 -5px",
            width: "140px",
            height: "45px",
            left: "55%",
            top: "265px",
          },
          tipStyle: {
            // tips样式
            left: "0px",
            top: "63px",
            atop: "60px"
          },
        },
        {
          el: ".faxin-guide_1", // 需要高亮的元素，这里最好唯一
          tips: "④ 下载完成后，点击这里", // 提示文字
          next: "下一步", // 下一步按钮显示文字
          style: {
            // 高亮样式
            borderRadius: "12px",
            margin: "-5px 0 0 -5px",
            width: "40px",
            height: "40px",
            left: "15px",
            top: "10px",
          },
          tipStyle: {
            // tips样式
            left: "0px",
            top: "53px",
            atop: "50px"
          },
        },
        {
          el: ".custom-btn", // 需要高亮的元素，这里最好唯一
          tips: "⑤ 点击这里", // 提示文字
          next: "下一步", // 下一步按钮显示文字
          style: {
            // 高亮样式
            borderRadius: "5px",
            margin: "-5px 0 0 -5px",
            width: "220px",
            height: "45px",
          },
          tipStyle: {
            // tips样式
            left: "50px",
            top: "-73px",
            atop: "-20px",
          },
        },
      ],
      isShowGuide: false,
      isShowGuide1: false,
    };
  },
  mounted() {
    this.getExminePath();
  },
  computed: {
    ...mapGetters(["deptId"]),
  },
  methods: {
    async toPath() {
      await this.$api.riders.otherStatus({ otherStatus: 90 });
      this.$u.route("pages/finish/index");
    },
    async getExminePath() {
      uni.showLoading({
        title: '加载中，请稍候...'
      });
      let { code,msg } = await this.$api.dormitory.getzhanzhangmingpian({ deptId: this.deptId }).catch(()=>{uni.hideLoading()});
      if (code == 200 && !isEmpty(msg)) {
        this.showGuide = false
        this.downloadImg = (window.location.href.includes('/xsdcrm-wechat-ui/')?consts.API_BASE_URL+'/xsdcrm-static/upload/': '/profile/') +  msg
      } else {
        this.showGuide = true
      }
      uni.hideLoading();
    },
    curIndex(num) {
      if (num === 2 || num === 3) {
        this.isShowGuide1 = true;
      } else {
        this.isShowGuide1 = false;
      }
      if (num === 1) {
          this.isShowGuide = true;
        } else {
          this.isShowGuide = false;
        }
    },
  },
};
</script>

<style lang="scss" scoped>
uni-page-body,
uni-view {
  height: 100%;
}
.iframe {
  height: 85vh;
}
.download-box{
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%,-50%);
  width: 200px;
  height: 200px;
  image{
    display: block;
    width: 100%;
    height: 100%;
  }
  .tips {
    display: block;
    width: 100%;
    text-align: center;
    color: #666;
    font-size: 12px;
    margin-top: 10px;
  }
}
.custom-btn {
  position: absolute;
  bottom: 10px;
  margin: 15px auto;
  left: 50%;
  transform: translateX(-50%);
}
.faxin-guide {
  width: 100%;
  height: 50vh;
  position: absolute;
  bottom: 0px;
  left: 0;
  background: url("../../common/imgs/xiazai.jpg") no-repeat;
  background-size: 100% 100%;
  z-index: 100;
}
.faxin-guide_1 {
  width: 100%;
  height: 480px;
  position: absolute;
  top: 0px;
  left: 0;
  background: url("../../common/imgs/xiazai_1.jpg") no-repeat;
  background-size: 100% 100%;
  z-index: 100;
}
</style>
